class Solution {
    public boolean containsNearbyAlmostDuplicate(int[] nums, int k, int t) {
        boolean ss = false;
        for(int i = 0;i < nums.length;i++) {
            if(!ss){
                for(int j = i+1;j < nums.length;j++) {
                    if(!ss && j-i<=k){
                        long a1 = (long)nums[j];
                        long a2 = (long)nums[i];
                        long a = 0;
                        if(a1 <= a2) {
                            a = a2 - a1;
                        } else{
                            a = a1 - a2;
                        }
                        if(a <= (long)t) {
                            ss = true;
                        }
                    } else{
                        break;
                    }
                }
            } else{
                break;
            }
        }
        return ss;
    }
}